package cn.itcast.day06.demo14发红包案例;

import java.util.ArrayList;

public class Manager extends User {
    public Manager() {
    }

    public Manager(String name, int money) {
        super(name, money);
    }

    public ArrayList<Integer> send(int totalMoney, int count) {
        ArrayList<Integer> redList = new ArrayList<>();
        int leftMoney = super.getMoney();
        if (totalMoney > leftMoney) {
            System.out.println("余额不足!");
            return redList;
        } else {
            super.setMoney(leftMoney - totalMoney);
            int avg = totalMoney / count;
            int mod = totalMoney % count;
            for (int i = 0; i < count; i++) {
                if(i==count-1){
                    redList.add(avg+mod);
                }else{
                    redList.add(avg);
                }
            }
        }
        return redList;
    }
}
